#include <stdio.h>

/**
 * 字符数据
 */
int main() {
	// 字符变量
	char c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11;

	/*
	 * 1、字符赋值
	 */
	printf("****SECTION 1****************************\n");
	c1 = 'g';
	c2 = '<';
	c3 = '\n';
	printf("c1 = %c, c2 = %c, c3 = %c\n", c1, c2, c3);
	// 打印一个字符
	putchar(c1);
	putchar(32);
	putchar(c2);
	putchar(c3);

	/*
	 * 2、字符串格式化输入字符
	 */
	printf("****SECTION 2****************************\n");
	printf("Enter two characters (spaces separated), then press enter\n");
	scanf("%c %c", &c4, &c5);
	putchar(c4);
	putchar(c5);
	printf("\nASCII CODE %d %d\n", c4, c5);

	/*
	 * 3、键盘输入字符
	 */
	printf("****SECTION 3****************************\n");
	printf("Enter two characters (spaces separated), then press enter\n");
	// 排除 enter key
	getchar();
	c6 = getchar();
	// 排除空格
	getchar();
	c7 = getchar();
	putchar(c6);
	putchar(c7);
	putchar('\n');

	/*
	 * 4、键盘输入字符，清空缓冲区
	 */
	printf("****SECTION 4****************************\n");
	printf("Enter two characters (spaces separated), then press enter\n");
	// 清空缓冲区
	fflush(stdout);
	// 当缓冲区没有数据时，会等待输入
	getchar();
	c8 = getchar();
	getchar();
	c9 = getchar();
	printf("c8 = %c, c9 = %c\n", c8, c9);
}